package com.moneyhelper.upms.config;

import com.alibaba.fastjson.JSONObject;
import com.moneyhelper.common.resp.RestResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author yanggld
 * @Date 2019/7/9-9:41
 * @Description
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

	@ResponseBody
	@ExceptionHandler(value = Exception.class)
	public RestResponse exceptionHandler(Exception ex){
		log.error("!!!!!!捕获异常:{}!!!!!!",ex.getMessage());
		ex.printStackTrace();
//		log.error("异常详细信息:{}", JSONObject.toJSONString());
		return RestResponse.ERROR(ex.getMessage());
	}


}
